package com.example.demo;

import com.example.demo.domain.Order;
import com.example.demo.order.OrderService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by fandg on 2020/3/31.
 */
@Service("orderService")
public class OrderServiceImpl implements OrderService {

    public static final List<Order> list;
    static {
        list = new ArrayList<>();
        list.add(new Order(10001,"apple2", new BigDecimal(9), "红富士苹果2"));
        list.add(new Order(10002,"orange2", new BigDecimal(6), "甜柑橘2"));
    }

    @Override
    public List<Order> orderList() {
        return list;
    }

    @Override
    public Order getOrder(Long id) {
        for (Order item: list) {
            if (item.getId() == id) {
                return item;
            }
        }
        return null;
    }
}
